package com.matrix.java.chap_18;

import java.math.BigInteger;

/**
 * 计算阶乘
 */
public class Ex18_01 {
    public static void main(String[] args) {
        BigInteger n = new BigInteger("10");
        System.out.println(factorial(n));
    }

    public static BigInteger factorial(BigInteger n) {
        if (n.equals(BigInteger.ZERO)) {
            return BigInteger.ONE;
        } else {
            return n.multiply(factorial(n.subtract(BigInteger.ONE)));
        }
    }
}
